//
//  UIBarButtonItemExtension.swift
//  SwiftDemo1
//
//  Created by wzp on 2025/6/2.
//

import Foundation
import UIKit

extension UIBarButtonItem {
    convenience init(imageName: String, target: AnyObject, action: Selector) {
        let btn = UIButton()
        btn.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
        btn.contentEdgeInsets = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5)
        btn.setImage(UIImage(named: imageName), for: .normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
        btn.addTarget(target, action: action, for: .touchUpInside)
        self.init(customView: btn)
    }
}
